package com.mrzhiyi.demo.sb;

import cn.hutool.core.lang.Console;
import com.mrzhiyi.demo.sb.common.utils.IpAddressUtils;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.context.WebServerApplicationContext;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@MapperScan(basePackages={"com.mrzhiyi.demo.sb.mapper"})
public class SbDemoApplication{
    public static void main(String[] args){
        SpringApplication.run(SbDemoApplication.class,args);
    }

    @Bean
    public ApplicationRunner applicationRunner(WebServerApplicationContext context){
        return (ApplicationArguments args)->{
            try{
                Console.log("===============项目启动成功===============");
                IpAddressUtils.getIpAddressOfStartUp(context)
                              .forEach(ip->Console.log("====== "+(ip+" ".repeat(26-ip.length()))+" ======="));
                Console.log("===============项目启动成功===============");
            }catch(Exception e){
                e.printStackTrace();
            }
        };
    }
}
